var express = require('express');
var router = express.Router();
const axios = require('axios');
const iconv = require('iconv-lite');
const cheerio = require('cheerio');
const { getWBTopSearch, getZHTopSearch, getBDTopSearch } = require('../plugin/handleDom')

/* GET home page. */
router.get('/get', async function (req, res, next) {
    const WBData = await getWBTopSearch();
    const ZHData = await getZHTopSearch();
    const BDData = await getBDTopSearch();
    res.send({
        code: 1,
        data: {
            WBData,
            ZHData,
            BDData,
        },
        msg: '获取成功'
    })
});

router.get('/getWB', async function (req, res, next) {
    const WBData = await getWBTopSearch();
    res.send({
        code: 1,
        data: WBData,
        msg: '获取成功'
    })
});

router.get('/getZH', async function (req, res, next) {
    const ZHData = await getZHTopSearch();
    res.send({
        code: 1,
        data: ZHData,
        msg: '获取成功'
    })
});

router.get('/getBD', async function (req, res, next) {
    const BDData = await getBDTopSearch();
    res.send({
        code: 1,
        data: BDData,
        msg: '获取成功'
    })
});

module.exports = router;